﻿var dict = {
    zh_CN: {
        messages: {
            required: function (field) {
                return '请输入' + field;
            }
        },
        attributes: {
            lgnName: '手机号',
            lgnPwd: '密码'
        }
    }
};
VeeValidate.Validator.localize('zh_CN', dict.zh_CN);
Vue.use(VeeValidate, { locale: 'zh_CN' });
$(function () {
    $('#divCode').slideVerify({
        type: 1,		//类型
        vOffset: 2,	//误差量，根据需求自行调整
        barSize: {
            width: '100%',
            height: '35px',
        },
        ready: function () {
        },
        success: function () {
            VMUser.loginInfo.lgnCode = true;
        },
        error: function () {
            //		        	alert('验证失败！');
        }
    });
})
var VMUser = new Vue({
    el: "#divUser",
    data: {
        loginInfo: {
            lgnName: "",
            lgnPwd: "",
            lgnCode: false
        }, url: {
            register: "/account/register",
            resetpwd: "/account/resetpwd"
        }
    },
    methods: {
        LoginUser: function () {
            var that = this;
            that.$validator.validateAll().then(function (result) {
                if (result) {
                    if (!that.loginInfo.lgnCode) {
                        that.$message({
                            message: '请滑动验证！',
                            type: 'warning'
                        });
                        return;
                    }
                    $.post("/Account/loginUser", that.loginInfo, function (data) {
                        if (data.suc) {
                            VMUser.$message({
                                message: data.msg,
                                type: 'success'
                            });
                            location.href = "/Home/Index";
                        }
                        else {
                            VMUser.$message.error(data.msg);
                        }
                    })
                }
                else {
                    that.message("页面上还有未填信息，请填写完整", "warning");
                }
            });  
        }
    }
})